package test3;

import java.util.Scanner;

public class Test {
    //计算各个位数字之和
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        String str = sc.next();
        int x = sc.next();
        int z = 0;
        for(int i = 0; i<str.length(); i++) {
            int a = Integer.parseInt(str.charAt(i)+"");
            z += a;
        }
        System.out.println("输入的数字是："+str+"，各位数字之和为："+z);




//判断是否是质数
        for(i=2;i<z;i++){
            if(z%i==0) break;
        }
        if(i==z){
            //判断是否是回文数
            String str1 = x + "";
            StringBuilder str2 = new StringBuilder(str1);
            str2.reverse();
            int count = 0;
            for (int j = 0; j < str1.length(); j++) {
                if (str1.charAt(j) != str2.charAt(j)) {
                    System.out.println(str1 + "不是回文数");
                    break;
                } else {
                    count++;
                }
            }
            if (count == str1.length()) {
                System.out.println(str1 + "是回文数");
            }

            System.out.println(z+"是质数.");

        } else {
//判断有多少种不同数字个数
            String str = scanner.next();
            char[] chars = str.toCharArray();
            Set set = new HashSet();
            for (char ch : chars) {
                set.add(ch);
            }
            System.out.println(z + "不是质数," + "共有" + set.size() + "种不同数字.");
        }



    }
}
